import json

from django.shortcuts import render
from django.http import HttpResponse, JsonResponse

# Create your views here.
from lexin.brush import main_handler


def test_url(request):
    return HttpResponse("hello step")


def step_url(request):
    msg = "少侠，方法弄错了吧，还是没有给点东西。。。"
    if request.method == 'POST':
        req_body = request.POST
        phone = str(req_body["phone"]) if req_body.get("phone") else ""
        password = str(req_body["password"]) if req_body.get("password") else ""
        mixstep = int(req_body["minstep"]) if req_body.get("minstep") else 30000
        maxstep = int(req_body["maxstep"]) if req_body.get("maxstep") else 40000
        msg = main_handler(phone, password,mixstep,maxstep)
    return HttpResponse(msg)
